﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CourseSystem.Core.Entities.StudentInfo>" %>
<%@ Import Namespace="CourseSystem.Common.Helpers" %>
<% using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "editDiv", }))
   {%>
<% Html.RenderPartial("HighLightMsgUc"); %>
<fieldset>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.Uid) %>
    </div>
    <div class="editor-field">
        <%: Html.TextBoxFor(model => model.Uid) %>
        <%: Html.ValidationMessageFor(model => model.Uid) %>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.PassWord) %>
    </div>
    <div class="editor-field">
        <%: Html.PasswordFor(model => model.PassWord)%><% if (Model.Id != 0)
                                                          {%>不强制修改请勿填写<%}  %>
        <%: Html.ValidationMessageFor(model => model.PassWord) %>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.StuName) %>
    </div>
    <div class="editor-field">
        <%: Html.TextBoxFor(model => model.StuName) %>
        <%: Html.ValidationMessageFor(model => model.StuName) %>
    </div>
    <div class="editor-label">
        学院
    </div>
    <div class="editor-field">
        <%=Html.DropDownList("CollegeIdFake", StudentHelper.GetCollege(), new { onchange = "collegeChange();" })%>
        <%: Html.ValidationMessage("CollegeIdFake")%>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.SubjectId) %>
    </div>
    <div class="editor-field">
        <%=Html.DropDownList("SubjectId", StudentHelper.GetSubject(Model.CollegeIdFake))%>
        <%: Html.ValidationMessageFor(model => model.SubjectId) %>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.GradeYear) %>
    </div>
    <div class="editor-field">
        <%=Html.DropDownList("GradeYear", StudentHelper.GetGradeYear())%>
        <%: Html.ValidationMessageFor(model => model.GradeYear) %>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.Class) %>
    </div>
    <div class="editor-field">
        <%=Html.DropDownList("Class", StudentHelper.GetClass())%>
        <%: Html.ValidationMessageFor(model => model.Class) %>
    </div>
    <p>
        <input type="submit" value="保存" />
    </p>
</fieldset>
<% }
   var college = 0;
   var subject = 0;
   var year = 0;
   var classId = 0;
   if (Model.Id != 0)
   {
       college = Model.SubjectInfo.CollegeId;
       subject = Model.SubjectId;
       year = Model.GradeYear;
       classId = Model.Class;
   }
%>
<script type="text/javascript">
    var collegeChange = function () {
        selectLoad("SubjectId", "Ajax/GetSubject/" + $("#CollegeIdFake").val());
    };
    $(function () {
        var college = "<%=college %>";
        var subject = "<%=subject %>";
        var year = "<%=year %>";
        var classId = "<%=classId %>";
        // selectLoad("CollegeId", "Ajax/GetCollege", college);
        //selectLoad("Class", "Ajax/GetClass", classId);
        //selectLoad("GradeYear", "Ajax/GetGradeYear", year);
        // selectChangeLoad("SubjectId", "CollegeId", "Ajax/GetSubject/");

        /* $("#CollegeId").val(college);
        $("#SubjectId").val(subject);
        $("#GradeYear").val(year);
        $("#Class").val(classId);*/
       // if (subject != 0) {
        //    $("#CollegeId").val(college);
        //    selectLoad("SubjectId", "Ajax/GetSubject/" + college, subject);
       // }
    });
</script>
